<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>禧乐仓连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<style>
.button1 {
	width: 40px;
	height: 20px;
	font-size: 12px;
	background-color: #008B8B;
	color: #fff;
	border: 1px solid #008B8B;
	border-radius: 5px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.button2 {
	width: 40px;
	height: 20px;
	font-size: 12px;
	background-color: #FFA500;
	color: #fff;
	border: 1px solid #FFA500;
	border-radius: 5px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.button3 {
	width: 40px;
	height: 20px;
	font-size: 12px;
	background-color: #DB7093;
	color: #fff;
	border: 1px solid #DB7093;
	border-radius: 5px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
</style>
<script>

var dataGrid ;
var isExpand = 0;
$(document).ready(function(){
	parent.$.messager.progress('close'); 
	
	$('#dataGrid').treegrid({
		url : 'basicDataJSON!selectSystemMenu',
		idField: 'id',
		treeField : 'menuName',
		columns : [[
					
					{field:'id', width:50,title:'ID'},
					{field:'menuName', width:290,title:'菜单名称'},
					{field:'menuPath', width:420,title:'菜单路径'},
					
					{field:'menuType',align:'center', width:125,title:'菜单类型',
					    formatter : function(value, row, index) {
					    	if(row.menuType === "M"){
					    		return '<div><button  class="button1" >'+"菜单"+'</button></div>';
					    	}else if(row.menuType === "C"){
					    		return '<div><button  class="button2" >'+"目录"+'</button></div>';
					    	}else if(row.menuType === "B"){
					    		return '<div><button  class="button3" >'+"按钮"+'</button></div>';
					    	}
					    	
					}},
					{field:'statusS',align:'center', width:105,title:'状态'},
					{field:'isHiddenS',align:'center', width:105,title:'是否隐藏'},
					{field:'sort',align:'center', width:85,title:'排序'},
					{field:'createBy',align:'center', width:115,title:'创建人'},
					{field:'createTimes', width:175,title:'创建时间'}, {				
						field : 'action',
						title : '编辑',
						width : 70,
						align: 'center',
						formatter : function(value, row, index) {
						var str = '';

							str += $.formatString('<a href="#" onclick="updateSystemMenu(\'{0}\');"><img border="0" src="{1}" title="编辑"/></a>', row.id, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update3.png');
										
						return str;
					}
				}
					
			     ]],
		toolbar : '#toolbar',
		onLoadSuccess: function(row, data) {
	        $(this).treegrid('collapseAll');  // 数据加载完毕后折叠所有节点 :ml-citation{ref="5,8" data="citationList"}
	    }
	});
});


function BSkeyDown(e){

	var ieKey = event.keyCode;
	        
} 

document.onkeydown = BSkeyDown; 


function addMenu(){
	var params = "";

	$.modalDialog.opener_dataGrid = dataGrid;
	
	$.modalDialog({
		title : "新增菜单信息",
		width : 680,
		height : 400,
		modal : false,
		draggable:false,
		href : 'userJSP!updateSystemMenu',
		
	});
}
function updateSystemMenu(id){
	if (id == undefined){
		var node = $('#dataGrid').treegrid('getSelected');
		if (node == null){
			$.messager.alert('错误', '请先选中一行再继续操作', 'error');
		} else {
			id = node.id;
		}
	}
	
	var params = "formBean.menu.id=" + id;
	$.modalDialog({
		title : "更新配置信息",
		width : 680,
		height : 400,
		modal : false,
		draggable:false,
		href : 'userJSP!updateSystemMenu?' + params,
		
	});
}

/**
 * 回调
 */
function callBack(data){
	$.messager.alert('提示',data.message);
	
}

function findSystemConfig(){
	dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
}

function oneKeyOperate(){
	if(isExpand == 0){
		$('#dataGrid').treegrid('expandAll');  
		isExpand = 1;
	}else{
		$('#dataGrid').treegrid('collapseAll');  
		isExpand = 0;
	}
}


function saveMenu(){
	   var params=$("#updateSystemMenuForm").serialize();
    $.post("basicDataJSON!updateSystemMenu",params, updateMenuBKProcess,"json");	
}
function updateMenuBKProcess(data){
	var response = data.response;
	var returnCode = response.returnCode;
	if (returnCode != SUCCESS)
		$.messager.alert('错误', response.message, 'error');
	else {
		$.modalDialog.handler.dialog('close');
		$('#dataGrid').treegrid('reload');
	}		
}
function cancel(){
	$.modalDialog.handler.dialog('close');
}

</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false" style="height: 90px;">
			<s:form id="barcodeSearchForm" name="barcodeSearchForm" action="" method="POST" theme="simple">
			   
				<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
										<tr>
											<td height="50" colspan="7">		
												<table width="100%" border="0">
													<input type="hidden" id="isInitialized" name="formBean.isInitialized" />
													<tr class="PBAOuterTableTitale">
														<td height="31" >系统菜单：
															
														</td>
													</tr>
												<tr>
																			
									<td>			
										<a onclick="addMenu();" href="javascript:void(0);"
											class="easyui-linkbutton c6" style="height:25px;"
											data-options="iconCls:'icon-search'">新增菜单</a>
											<a onclick="oneKeyOperate();" href="javascript:void(0);"
											class="easyui-linkbutton c6" style="height:25px;"
											data-options="iconCls:'icon-tip'">一键展开/折叠</a>
											<a onclick="updateSystemMenu();" href="javascript:void(0);"
											class="easyui-linkbutton c6" style="height:25px;"
											data-options="iconCls:'icon-edit'">修改菜单</a>										 
									</td>													
				

									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>


			</s:form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dataGrid" border="0">
			</table>
						 
		</div>

	</div>
</body>
</html>